#define _CRT_SECURE_NO_WARNINGS 1
#include"string.h"
using namespace std;

void test1()
{
	wjb::string s1;
	wjb::string s2("hello world!!!");
	cout << s1.c_str() << endl;
	cout << s2.c_str() << endl;
}

void test2()
{
	wjb::string s1;
	wjb::string s2("hello world!!!");
	const wjb::string s3("hello world!!!");
	for (size_t i = 0; i < s2.size(); i++)
	{
		cout << s2[i] << " ";
	}
	cout << endl;
	for (size_t i = 0; i < s2.size(); i++)
	{
		s2[i]++;
	}
	for (size_t i = 0; i < s2.size(); i++)
	{
		cout << s2[i] << " ";
	}
	cout << endl;
	for (size_t i = 0; i < s2.size(); i++)
	{
		cout << s3[i] << " ";
	}
	cout << endl;

	wjb::string::iterator it = s2.begin();
	while (it < s2.end())
	{
		cout << *it;
		it++;
	}
	cout << endl;

	for (auto ch : s2)
	{
		cout << ch;
	}
	cout << endl;
}


void test3()
{
	wjb::string s1 = "hello";
	wjb::string s2 = "hello";
	s1.pushback('a');
	s2.append(" world");
	cout << s1.c_str() << endl;
	cout << s2.c_str() << endl;
	s1 += 'b';
	cout << s1.c_str() << endl;
}

void test4()
{
	wjb::string s1 = "helloworld";
	wjb::string s2 = "hellolinux";
	s1.insert(5,5,'#');
	s2.insert(5, "!!!!!");
	cout << s1.c_str() << endl;
	cout << s2.c_str() << endl;

	s1.erase(11, 2);
	cout << s1.c_str() << endl;
	
	s2.erase(13,2);
	cout << s2.c_str() << endl;
}

void test5()
{
	wjb::string url = "http://www.baidu.com/u@qqq20kvcv0fd0123-4";
	size_t pos1 = url.find("://", 0);
	wjb::string s = url.substr(0, pos1);
	cout << s.c_str() << endl;

}

int main()
{
	//test1();
	//test2();
	//test3();
	//test4();
	test5();
	return 0;
}
